<div class="ui-g-12 p-20">
  <p-panel headerClass="bg-none" [showScroll]="true" marginHeight='80'>
    <p-header>
      <div class="text-right p-6-0">
        <span class="border-l-1a8fe8 p-l-8 pull-left m-t-8 ">{{title}}</span>
        <button pButton type="button" (click)="save()" class="btn {{checkId?'btn-secondary':'btn-success'}}" label="保存"></button>
        <button pButton type="button" (click)="back()" label="取消" class="btn btn-secondary"></button>
      </div>
    </p-header>

    <form #form="ngForm" novalidate class="form-horizontal">
      <div class="ui-lg-12 ui-md-12 ui-g-nopad head-title">
        验收信息
      </div>

      <div class="table-row">
        <div class="table-cell text-right p-l-25 p-required">
          编号：
        </div>
        <div class="table-cell min-width">
          <input type="text" pInputText class="p-input" name="code" required [(ngModel)]="checkManage.code" placeholder="请输入编号" (blur)="checkCodeCk();"
            (focus)="checkCodeError =''" [disabled]="checkId" [ngClass]="checkCodeError?'p-input-error':''">
        </div>
        <div class="table-cell">
          <p-message *ngIf="checkCodeError" severity="error" [text]="checkCodeError"></p-message>
        </div>
      </div>

      <div class="table-row">
        <div class="table-cell text-right p-l-25 p-required">
          名称：
        </div>
        <div class="table-cell min-width">
          <input pInputText class="p-input" name="name" required maxlength="25" [(ngModel)]="checkManage.name" (blur)="checkNameCk();"
            (focus)="checkNameError =''" placeholder="请输入验收项名称" [ngClass]="checkNameError?'p-input-error':''">
        </div>
        <div class="table-cell">
          <p-message *ngIf="checkNameError" severity="error" [text]="checkNameError"></p-message>
        </div>
      </div>

      <div class="table-row">
        <div class="table-cell text-right p-l-25 p-required">
          是否预警：
        </div>
        <div class="table-cell min-width">
          <p-dropdown required name="isWarning" [options]="isWarningStatus" dataKey="id" placeholder="请选择是否需要预警" [style]="{width: '100%'}"
            [(ngModel)]="selectedWarningStatus" optionLabel="name" dataKey="code" (onChange)="isWarningStatusCk()"></p-dropdown>
        </div>
        <div class="table-cell">
          <p-message *ngIf="isWarningError" severity="error" [text]="isWarningError"></p-message>
        </div>
      </div>

      <div class="table-row">
        <div class="table-cell text-right p-l-25">
          预警天数：
        </div>
        <div class="table-cell icon-text min-width" data-text="天">
          <p-spinner name="warningDays" size="30" maxlength="6" styleClass="p-spinner" [(ngModel)]="checkManage.warningDays" placeholder="请输入预警天数"
            (onFocus)="warningDaysError =''" (onBlur)="warningDaysCk();" [step]="1" [min]="0" [max]="99999" [disabled]="selectedWarningStatus?.code === false"></p-spinner>
        </div>
        <div class="table-cell">
          <p-message *ngIf="warningDaysError" severity="error" [text]="warningDaysError"></p-message>
        </div>
      </div>

      <div class="table-row">
        <div class="table-cell text-right p-l-25 p-required">
          是否客户确认：
        </div>
        <div class="table-cell min-width">
          <p-dropdown required name="isCustomConfirm" [options]="isCustomConfirm" dataKey="id" placeholder="请选择是否客户确认" [style]="{width: '100%'}"
            [(ngModel)]="selectedConfirm" optionLabel="name" dataKey="code" (onChange)="isCustomConfirmCk()"></p-dropdown>
        </div>
        <div class="table-cell">
          <p-message *ngIf="isCustomConfirmError" severity="error" [text]="isCustomConfirmError"></p-message>
        </div>
      </div>

      <div class="table-row">
        <div class="table-cell text-right p-l-25">
          自动确认天数：
        </div>
        <div class="table-cell icon-text min-width" data-text="天">
          <p-spinner name="confirmDays" size="30" maxlength="6" styleClass="p-spinner" [(ngModel)]="checkManage.confirmDays" placeholder="请输入自动确认天数"
            (onFocus)="confirmDaysError =''" (onBlur)="confirmDaysCk();" [step]="1" [min]="0" [max]="99999" [disabled]="selectedConfirm?.code === false"></p-spinner>
        </div>
        <div class="table-cell">
          <p-message *ngIf="confirmDaysError" severity="error" [text]="confirmDaysError"></p-message>
        </div>
      </div>


      <div class="table-row">
        <div class="table-cell text-right p-l-25">
          提醒方式：
        </div>
        <div class="table-cell">
          <!--<p-radioButton name="alertMethod" value="alerttype_message" (click)="clickSelectAlertMethod()" label="短信" [(ngModel)]="selectAlertMethod"-->
          <!--inputId="opt1"></p-radioButton>-->
          <!--<p-radioButton name="alertMethod" value="alerttype_app" (click)="clickSelectAlertMethod()" label="app" [(ngModel)]="selectAlertMethod"-->
          <!--inputId="opt2"></p-radioButton>-->

          <p-checkbox name="alertMethod" value="alerttype_message" label="短信" [(ngModel)]="selectAlertMethod" inputId="opt1"></p-checkbox>
          <p-checkbox name="alertMethod" value="alerttype_app" label="APP" [(ngModel)]="selectAlertMethod" inputId="opt2"></p-checkbox>
        </div>
        <div class="table-cell">
          <p-message *ngIf="selectAlertMethodError" severity="error" [text]="selectAlertMethodError"></p-message>
        </div>
      </div>

      <div class="table-row">
        <div class="table-cell text-right p-l-25 p-required">
          是否需要评价：
        </div>
        <div class="table-cell min-width">
          <p-dropdown required name="isCustomDiscuss" [options]="isCustomDiscussStatus" dataKey="id" placeholder="请选择是否需要评价" [style]="{width: '100%'}"
            [(ngModel)]="selectedCustomDiscuss" optionLabel="name" dataKey="code" (onChange)="isCustomDiscussCk()"></p-dropdown>
        </div>
        <div class="table-cell">
          <p-message *ngIf="isCustomDiscussError" severity="error" [text]="isCustomDiscussError"></p-message>
        </div>
      </div>

      <div class="table-row">
        <div class="table-cell text-right p-l-25">
          未评价提醒天数：
        </div>
        <div class="table-cell icon-text min-width" data-text="天">
          <p-spinner name="noDiscussAlertDays" size="30" maxlength="6" styleClass="p-spinner" [(ngModel)]="checkManage.noDiscussAlertDays"
            placeholder="请输入未评价提醒天数" (onFocus)="noDiscussAlertDaysError =''" (onBlur)="noDiscussAlertDaysCk();" [step]="1"
            [min]="0" [max]="99999" [disabled]="selectedCustomDiscuss?.code === false"></p-spinner>
        </div>
        <div class="table-cell">
          <p-message *ngIf="noDiscussAlertDaysError" severity="error" [text]="noDiscussAlertDaysError"></p-message>
        </div>
      </div>

      <div class="table-row">
        <div class="table-cell text-right p-l-25 p-required">
          客户回访：
        </div>
        <div class="table-cell min-width">
          <p-dropdown required name="isCustomBack" [options]="isCustomBackStatus" dataKey="id" placeholder="请选择是否客户回访" [style]="{width: '100%'}"
            [(ngModel)]="selectedIsCustomBack" optionLabel="name" dataKey="code" (onChange)="isCustomBackCk()"></p-dropdown>
        </div>
        <div class="table-cell">
          <p-message *ngIf="isCustomBackError" severity="error" [text]="isCustomBackError"></p-message>
        </div>
      </div>

      <div class="table-row" *ngIf="checkId">
        <div class="table-cell text-right p-l-25 p-required">
          状态：
        </div>
        <div class="table-cell min-width">
          <p-dropdown required name="isEffect" [options]="isEffects" dataKey="id" placeholder="请选择状态" [style]="{width: '100%'}" [(ngModel)]="selectedisEffect"
            optionLabel="name" dataKey="code" (onChange)="isEffectCk()"></p-dropdown>
        </div>
        <div class="table-cell">
          <p-message *ngIf="isEffectError" severity="error" [text]="isEffectError"></p-message>
        </div>
      </div>

      <div class="b-b-ebebeb"></div>

      <div class="table-row">
        <div class="table-cell text-right p-l-25 p-required">
          验收说明：
        </div>
        <div class="table-cell">
          <button pButton type="button" label="添加" (click)="addConStandard()" class="btn btn-success"></button>
          <p-message *ngIf="standardError" severity="error" [text]="standardError"></p-message>
        </div>
      </div>
      <div class="dataTable">
        <p-dataTable [value]="conStandardList" [lazy]="true" [paginator]="false" [editable]="true">
          <p-column *ngFor="let col of colsConStandard" [field]='col.field' [header]='col.header' [editable]="col.editable" [style]="{'width':col.width}">

            <ng-template pTemplate="header" *ngIf="col.required">
              <div *ngIf="col.field === 'content'" class="p-required required">
                {{col.header}}
              </div>
            </ng-template>

            <ng-template let-index="rowIndex" let-data="rowData" pTemplate="body" *ngIf="col.tem">
              <div *ngIf="col.field === 'sortNum'">
                {{index + 1}}
              </div>
              <div *ngIf="col.field === 'operation'">
                <span class="move" (click)="removeConStandard(index)">删除</span>
                <span (click)="conStandardMoveUp(index)" class="move">上移</span>
                <span (click)="conStandardMoveDown(index)" class="move">下移</span>
              </div>
              <div *ngIf="col.field === 'content'">
                <div [class.p-input-error]="checkContent(data.content)" class="flex-td" [pTooltip]="checkContentIsNull(data.content) " errorTip="true"
                  tooltipPosition="top">
                  {{data.content}}
                </div>
              </div>
            </ng-template>
            <ng-template let-index="rowIndex" let-data="rowData" pTemplate="editor" *ngIf="col.tem">
              <div *ngIf="col.field === 'content'">
                <input type="text" pInputText  [name]="'content'+index" maxlength="100" class="p-input" required [(ngModel)]="data.content"
                  placeholder="请输入施工标准">
              </div>
            </ng-template>
          </p-column>
        </p-dataTable>
      </div>

      <div class="b-b-ebebeb"></div>


      <div class="table-row">
        <div class="table-cell text-right p-l-25">
          验收标准：
        </div>
        <div class="table-cell">
          <button pButton type="button" label="添加" (click)="addStandard()" class="btn btn-success"></button>
          <p-message *ngIf="saddStandardError" severity="error" [text]="saddStandardError"></p-message>
        </div>
      </div>
      <div class="dataTable">
        <p-dataTable [scrollable]="true" [value]="checkStandardList" [lazy]="true" [paginator]="false" [editable]="true" [customWidth]="true">
          <p-column *ngFor="let col of colsCheckStandard" [field]='col.field' [header]='col.header' [editable]="col.editable" [style]="{'width':col.width}">

            <ng-template pTemplate="header" *ngIf="col.required">
              <div *ngIf="col.field === 'checkStandard'" class="p-required required">
                {{col.header}}
              </div>
              <div *ngIf="col.field === 'phoneRequire' " class="p-required required">
                {{col.header}}
              </div>
            </ng-template>

            <ng-template let-index="rowIndex" let-data="rowData" pTemplate="body" *ngIf="col.tem">
              <div *ngIf="col.field === 'operation'">
                <span class="move" (click)="removeCheckStandard(index)">删除</span>
                <span class="move" (click)="checkStandardMoveUp(index)">上移</span>
                <span class="move" (click)="checkStandardMoveDown(index)">下移</span>
              </div>
              <div *ngIf="col.field === 'phoneRequire'">
                <div [class.p-input-error]="checkPhotos(data.phoneRequire)" class="flex-td" [pTooltip]="checkPgotosIsNull(data.phoneRequire) "
                  errorTip="true" tooltipPosition="top">
                  ≥{{data.phoneRequire}}
                </div>
              </div>
              <div *ngIf="col.field === 'isRequestPassItem'">
                {{data.isRequestPassItem.name}}
              </div>
              <div *ngIf="col.field === 'sortNum'">
                {{index + 1}}
              </div>
              <div *ngIf="col.field === 'checkStandard'">
                <div [class.p-input-error]="checkStandard(data.checkStandard)" class="flex-td" [pTooltip]="checkStandardIsNull(data.checkStandard) "
                  errorTip="true" tooltipPosition="top">
                  {{data.checkStandard}}
                </div>
              </div>
              <div class="flex-td" *ngIf="col.field === 'checkItem' || col.field === 'tackPhoneRequire' || col.field === 'toolConfig'">
                {{data[col.field]}}
              </div>
            </ng-template>

            <ng-template let-index="rowIndex" let-data="rowData" pTemplate="editor" *ngIf="col.tem">
              <div *ngIf="col.field === 'phoneRequire'">
                <p-spinner [name]="'phoneRequire'+index" size="30" maxlength="6" required styleClass="p-spinner" [(ngModel)]="data.phoneRequire"
                  [step]="1" [min]="0" [max]="99999" placeholder="请输入照片"></p-spinner>
              </div>
              <div *ngIf="col.field === 'isRequestPassItem'">
                <p-dropdown [name]="'isRequestPassItem'+index" [(ngModel)]="data[col.field]" optionLabel="name" dataKey="code" [autoWidth]="false"
                  [options]="isRequestPassItemArr" [style]="{'width':'100%'}" appendTo="body"></p-dropdown>
              </div>
              <div *ngIf="col.field === 'checkStandard'">
                <input type="text" pInputText [name]="col.field+index" class="p-input" required [(ngModel)]="data[col.field]" placeholder="请输入验收标准"
                  maxlength="50">
              </div>
              <div *ngIf=" col.field === 'checkItem'">
                <input type="text" pInputText [name]="col.field+index" class="p-input" required [(ngModel)]="data[col.field]" placeholder="请输入检查项目"
                  maxlength="100">
              </div>
              <div *ngIf="col.field === 'tackPhoneRequire'">
                <input type="text" pInputText [name]="col.field+index" class="p-input" required [(ngModel)]="data[col.field]" placeholder="请输入拍照要求"
                  maxlength="100">
              </div>
              <div *ngIf="col.field === 'toolConfig'">
                <input type="text" pInputText [name]="col.field+index" class="p-input" required [(ngModel)]="data[col.field]" placeholder="请输入基本配备工具"
                  maxlength="30">
              </div>
            </ng-template>
          </p-column>
        </p-dataTable>
      </div>





    </form>
  </p-panel>
</div>
